home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-21 | 4.9 KB | 202 lines | [TEXT/CWIE] |
- //===================================================================
- //======================= Headers =============================
-
- #include "NewWindowWindow.h"
- #include "GameUtilities.h"
- #include "Screen.h"
- #include "ApplicationHandler.h"
- #include "ApplicationEvents.h"
-
- //===================================================================
- //======================= Globals =============================
-
-
- //===================================================================
- //======================= #define =============================
-
-
- //===================================================================
- //======================= Function Prototypes =====================
-
-
- /*----------------------------------------------------------------------------\
-
- NewWindowWindow :: Constructor
-
- \----------------------------------------------------------------------------*/
- NewWindowWindow :: NewWindowWindow( void )
- : Window()
- {
- okDown = false;
- MySetRectWH( &okButton , 347 , 38 , 68 , 28 );
- }
-
-
- /*----------------------------------------------------------------------------\
-
- NewWindowWindow :: Init
-
- \----------------------------------------------------------------------------*/
- Boolean NewWindowWindow :: Init( void )
- {
- width = 433;
- height = 350;
- if( window.NewBuff( width , height ) )
- {
- OffScreenBuff backGround;
-
- backGround.LoadPicBuff( 142 );
-
- DrawPicture( &backGround , &backGround.GetBoundsSize(),
- &window , &window.GetBoundsSize() );
-
- screenLoc.left = 200;
- screenLoc.top = 200;
- screenLoc.right = screenLoc.left + width;
- screenLoc.bottom = screenLoc.top + height;
-
- return true;
- }
-
- return false;
- }
-
- /*----------------------------------------------------------------------------\
-
- NewWindowWindow :: HandleMouseClick
-
- \----------------------------------------------------------------------------*/
- void NewWindowWindow :: HandleMouseClick( Boolean down , point where )
- {
- if( down )
- {
- draging = true;
- start = where;
-
- where.x -= screenLoc.left;
- where.y -= screenLoc.left;
-
- if( SectPtRect( where , okButton ) )
- {
- OffScreenBuff buttonDown;
- rect blarg;
-
- buttonDown.LoadPicBuff( 143 );
- DrawPicture( &buttonDown , &buttonDown.GetBoundsSize(),
- &window , &okButton );
-
- blarg.left = screenLoc.left + okButton.left;
- blarg.right = screenLoc.left + okButton.right;
- blarg.top = screenLoc.top + okButton.top;
- blarg.bottom = screenLoc.top + okButton.bottom;
-
- screen.AddRectToUpdate( blarg );
- // draw it down
- okDown = true;
- }
- }
- else
- {
- if( okDown )
- {
- AH.SendEventToCurrentApp( kAEProgramSpec , NULL );
- }
-
- if( draging )
- {
- screen.AddRectToUpdate( screenLoc );
-
- MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
-
- screen.AddRectToUpdate( screenLoc );
-
- draging = false;
- }
- }
- }
-
- /*----------------------------------------------------------------------------\
-
- NewWindowWindow :: HandleMouseMove
-
- \----------------------------------------------------------------------------*/
- void NewWindowWindow :: HandleMouseMove( point where )
- {
- if( draging )
- {
- screen.AddRectToUpdate( screenLoc );
-
- MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
- start = where;
-
- screen.AddRectToUpdate( screenLoc );
- }
- }
-
- /*----------------------------------------------------------------------------\
-
- NewWindowWindow :: PointInWindow
-
- - just saids if the point it inside the window area or not
- \----------------------------------------------------------------------------*/
- Boolean NewWindowWindow :: PointInWindow( point where )
- {
- return SectPtRect( where , screenLoc );
- }
-
- /*----------------------------------------------------------------------------\
-
- NewWindowWindow :: Active
-
- \----------------------------------------------------------------------------*/
- Boolean NewWindowWindow :: Front( void )
- {
- return( front );
- }
-
- /*----------------------------------------------------------------------------\
-
- NewWindowWindow :: SetFront
-
- \----------------------------------------------------------------------------*/
- void NewWindowWindow :: SetFront( Boolean f )
- {
- if( f != front )
- {
- front = f;
- screen.AddRectToUpdate( screenLoc );
- }
- }
-
- /*----------------------------------------------------------------------------\
-
- NewWindowWindow :: DrawToScreen
-
- \----------------------------------------------------------------------------*/
- void NewWindowWindow :: DrawToScreen( rect *where , Boolean backGround )
- {
- if( front && !backGround )
- {
- if( where == NULL )
- {
- screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
- NULL , 0 , 0 , 0 );
- }
- else
- {
- screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
- where , 0 , 0 , 0 );
- }
- }
- else
- {
- if( where == NULL )
- {
- screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
- NULL , kDrawTint , 16 , 0xffff );
- }
- else
- screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
- where , kDrawTint , 16 , 0xffff );
- }
- }